#include "../aip-cpp-sdk/speech.h"

void asr(aip::Speech& client)
{
    // 无可选参数调用接口
    std::string file_content;
    aip::get_file_content("16k.pcm", &file_content);
    // 极速版调用函数
    // Json::Value result = client.recognize_pro(file_content, "pcm", 16000, aip::null);

    // 如果需要覆盖或者加入参数
    std::map<std::string, std::string> options;
    options["dev_pid"] = "1537";
    //设置为默认选项直接把options改为aip::null
    Json::Value result = client.recognize(file_content, "pcm", 16000, options);
    if(result["err_no"].asInt() != 0)
    {
        std::cout << result["err_msg"].asString() << std::endl;
        return;
    }
    std::cout << result["result"][0].asString() << std::endl;
}

// 设置APPID/AK/SK
int main()
{
    std::string app_id = "120291017";
    std::string api_key = "BMgDVm4hBigsm2ng6T0BRMgj";
    std::string secret_key = "TOe3Ir1kgf1yxRQmNjnPMe0XvHoJcLxk";

    aip::Speech client(app_id, api_key, secret_key);

    asr(client);
}

